﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Application.Command.LambWeaningCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;

namespace SheepStorage.API.Controllers
{
    /// <summary>
    /// 羔羊断奶
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LambWeaningController : ControllerBase
    {
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public LambWeaningController(IMediator mediator)
        {
            _mediator = mediator;
        }


        /// <summary>
        /// 羔羊断奶新增
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> LambWeaningAdd(LambWeaningCreateCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 羔羊断奶列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Results<List<LambWeaning>>> GetSheepWeaning([FromQuery] LambWeaningSelectCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 羔羊断奶逻辑删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<Results<int>> DeleteLambWeaning(LambWeaningDeleteCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 羔羊断奶单个数据
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Results<LambWeaning>> LambWeaningInfo([FromQuery] LambWeaningFillCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 羔羊断奶修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> UpdateLambWeaning(LambWeaningUpdateCommand command)
        {
            return await _mediator.Send(command);
        }

    }
}
